//
//  ST_PairsCenterPeculiarityQuartDetailCell.swift
//  btvideo
//
//  Created by mac on 2020/1/10.
//  Copyright © 2020 JarvanZhang. All rights reserved.
//

import UIKit
import SnapKit
import SwifterSwift


//四张图
class ST_AICenterPeculiarityQuartDetailCell : ST_AICenterPeculiarityDetailCell {
    
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        images_container_view.addSubview(coverImageView1)
        images_container_view.addSubview(coverImageView2)
        images_container_view.addSubview(coverImageView3)
        images_container_view.addSubview(coverImageView4)
        
        coverImageView1.snp.makeConstraints { (make) in
            make.top.equalToSuperview()
            make.left.equalToSuperview()
            make.right.equalTo(coverImageView2.snp.left).offset(-1)
            make.bottom.equalTo(coverImageView3.snp.top).offset(-1)
        }
        
        coverImageView2.snp.makeConstraints { (make) in
            make.right.equalToSuperview()
            make.top.height.width.equalTo(coverImageView1)
        }
        
        coverImageView3.snp.makeConstraints { (make) in
            make.left.height.width.equalTo(coverImageView1)
            make.bottom.equalToSuperview()
        }
        
        coverImageView4.snp.makeConstraints { (make) in
            make.height.width.equalTo(coverImageView1)
            make.left.equalTo(coverImageView2)
            make.top.equalTo(coverImageView3)
        }
        
        
        
        
        
        
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    fileprivate lazy var coverImageView1:ST_PairsCenterPeculiarityImageView = {
        let control = ST_PairsCenterPeculiarityImageView()
        control.contentMode = UIView.ContentMode.scaleAspectFill
        return control
    }()
    
    fileprivate lazy var coverImageView2:ST_PairsCenterPeculiarityImageView = {
        let control = ST_PairsCenterPeculiarityImageView()
        control.contentMode = UIView.ContentMode.scaleAspectFill
        return control
    }()
    
    fileprivate lazy var coverImageView3:ST_PairsCenterPeculiarityImageView = {
        let control = ST_PairsCenterPeculiarityImageView()
        control.contentMode = UIView.ContentMode.scaleAspectFill
        return control
    }()
    
    fileprivate lazy var coverImageView4:ST_PairsCenterPeculiarityImageView = {
        let control = ST_PairsCenterPeculiarityImageView()
        control.contentMode = UIView.ContentMode.scaleAspectFill
        return control
    }()
    
    override func bind_model_view() {
        super.bind_model_view()
        
        
        if let item = self.model.detail.first,let url = item.content.compress_image().url{

            coverImageView1.pin_setImage(from: url, placeholderImage: ST_SwiftConst.shared.fetch_random_place_holder_image())
            coverImageView1.isCheck = item.state == 1
        }
        
        if let item = self.model.detail[safe:1],let url = item.content.compress_image().url{

            coverImageView2.pin_setImage(from: url, placeholderImage: ST_SwiftConst.shared.fetch_random_place_holder_image())
            coverImageView2.isCheck = item.state == 1
        }
        
        if let item = self.model.detail[safe:2],let url = item.content.compress_image().url{

            coverImageView3.pin_setImage(from: url, placeholderImage: ST_SwiftConst.shared.fetch_random_place_holder_image())
            coverImageView3.isCheck = item.state == 1
        }
        
        if let item = self.model.detail[safe:3],let url = item.content.compress_image().url{

            coverImageView4.pin_setImage(from: url, placeholderImage: ST_SwiftConst.shared.fetch_random_place_holder_image())
            coverImageView4.isCheck = item.state == 1
        }
//        #if DEBUG
//        coverImageView1.backgroundColor = Color.random
//        coverImageView2.backgroundColor = Color.random
//        coverImageView3.backgroundColor = Color.random
//        coverImageView4.backgroundColor = Color.random
//        #endif
    }
}

